package com.iyoudoock.citymine.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;

import com.iyoudoock.citymine.constants.Key;
import com.kvin.toolkit.activity.OnBindInit;
import com.kvin.toolkit.utils.PersistentUtils;
import com.kvin.toolkit.utils.http.JsonHttpResponse;
import com.kvin.toolkit.utils.http.JsonUtils;

import org.json.JSONObject;

import java.io.IOException;
import java.util.HashMap;

/**
 * Created by Kvin on 2017/6/1.
 */
public class BaseFragment extends Fragment implements OnBindInit, JsonHttpResponse {
    protected JsonUtils mJsonUtils;
    protected HashMap<String, String> mParams;


    private boolean isInitialized;

    protected PersistentUtils mPersistentUtils;
    protected String mUid;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPersistentUtils = PersistentUtils.getInstance(getActivity(), PersistentUtils.XmlFile.USER_INFO);
        mUid = mPersistentUtils.readString(Key.User.UID);
        isInitialized = false;
    }


    @Override
    public void onStart() {
        super.onStart();
        if (!isInitialized) {
            isInitialized = true;
            initNav();
            init();
            loadingData();
        }
    }

    @Override
    public void onSuccess(JSONObject jsonObject, String flag) {

    }

    @Override
    public void onPreExecute(String flag) {

    }

    @Override
    public void onFailure(IOException e, String flag) {

    }

    @Override
    public void init() {

    }

    @Override
    public void initNav() {

    }

    /**
     * should be called in "onResume"
     */
    @Override
    public void initDialog() {

    }

    @Override
    public void loadingData() {

    }
}
